(define-module (fiio terraform)
  #:use-module ((guix licenses) #:prefix license:)
  #:use-module (guix build-system trivial)
  #:use-module (guix download)
  #:use-module (guix packages)
  #:use-module (gnu packages base)
  #:use-module (gnu packages compression))
;; 
(define-public terraform
  (package
    (name "terraform")
    (version "0.13.2")
    (source (origin
              (method url-fetch)
              (uri (string-append
                    "https://releases.hashicorp.com/terraform/"
                    version "/terraform_" version "_linux_amd64.zip"))
              (sha256
               (base32
                "0im7bfs9bfjkyiv7ikfx3x84ymjh6ivnbskaja2rw6fbqm06873c"))))
    (build-system trivial-build-system)
    (arguments
     `(#:builder (begin
                   (use-modules (guix build utils))
                   (let* ((unzip
                           (string-append (assoc-ref %build-inputs "unzip")
                                          "/bin/unzip"))
                          (source (assoc-ref %build-inputs "source"))
                          (out    (assoc-ref %outputs "out"))
                          (bindir (string-append out "/bin"))
                          (zipdir (string-append out "/"  ,(string-append name "-" version))))
                     (mkdir-p bindir)
                     (symlink bindir zipdir)
                     (with-directory-excursion bindir
                       (invoke unzip source))
                     (delete-file zipdir)
                     #t))
       #:modules ((guix build utils))))
    (native-inputs `(("unzip" ,unzip)))
    (supported-systems '("x86_64-linux"))
    (home-page "https://terraform.io")
    (synopsis "infrastructure as code")
    (description "terraform allows you to use Infrastructure as Code
to provision and manage any cloud, infrastructure or service.")
    (license license:mpl2.0)))

terraform
